package com.eso.frame.task;

import com.eso.frame.core.BaseService;
import com.eso.frame.task.job.RunningJobManager;
import org.apache.log4j.Logger;

import javax.annotation.Resource;

/**
 * 定时任务抽象类
 * User: Noah.Rong
 * Version: 0.1,  2012-05-22 15:59
 */
public abstract class SpringContextTask extends BaseService implements ISpringContextTask {

    protected Logger logger = Logger.getLogger(this.getClass());

    @Resource(name = "executingJobsManager")
    private RunningJobManager jobManager;

    public void executeTaskByHand() throws TaskException {
        logger.info("executeTaskByHand is starting ");
        jobManager.triggerRunningJobByHand(this);
        this.executeTask();
        jobManager.perishRunningJobByHand(this);
        logger.info("executeTaskByHand end ");
    }
}
